#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
    int n = 0, x = 0;
    cin >> n >> x;
    vector<int> a(n + 1, 0);
    for (int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int index = max(0, n - x);
    long long ret = 0;
    ret += a[index] * x;
    for (int i = index + 1;i <= n;i++)
    {
        ret += a[i] - a[index];
    }
    cout << ret << endl;
    return 0;
}